package cate.game.fight;

import cate.game.GameBody;
import cate.game.fight.hallow.BattleHallowBuilder;
import cate.game.fight.hero.BattleHeroBuilder;
import cate.game.fight.pet.BattlePetBuilder;
import cate.game.fight.position.PositionHandler;
import cate.game.fight.task.FightTaskHandler;
import cate.game.framework.ModuleMan;
import cate.game.play.part.SideBuilder;
import cate.game.play.support.PlayBuildContext;
import cate.game.play.support.PlayBuildContext4Game;
import easy.java.dev.note.NoteClass;
import easy.java.dev.note.NoteField;

@NoteClass("战斗模块管理")
public class FightManager extends ModuleMan {

    @NoteField("阵法处理")
    public PositionHandler position = new PositionHandler();

    @NoteField("上阵英雄builder")
    public BattleHeroBuilder hero = new BattleHeroBuilder();

    @NoteField("上阵圣器builder")
    public BattleHallowBuilder hallow = new BattleHallowBuilder();

    @NoteField("上阵灵宠builder")
    public BattlePetBuilder pet = new BattlePetBuilder();

    @NoteField("战斗一方处理")
    public SideBuilder side = new SideBuilder();

    @NoteField("任务处理")
    public FightTaskHandler task = new FightTaskHandler();

    private PlayBuildContext pbc;

    public PlayBuildContext getPlayBuildContext() {
        return this.pbc;
    }

    @Override
    public void initIndependent(GameBody game) throws Exception {
        super.initIndependent(game);

        this.pbc = new PlayBuildContext4Game(game);

        this.position.initIndependent(game);
        this.hero.init(this.pbc);
        this.hallow.init(this.pbc);
        this.pet.init(this.pbc);
        this.side.init(this.pbc);
        this.task.initIndependent(game);
    }

    @Override
    public void initDependent() throws Exception {

    }

    @Override
    public synchronized void shutdown(){
        this.task.shutdownSafe();
    }
}
